<?php
include_once 'include.php';
$total = sql_count('lyy_message','del=1');#总行数
$curr = isset($_REQUEST['curr'])?$_REQUEST['curr']:1;#当前页
$limit = 10;#每页多少行
$page = ceil($total/$limit);#总共有多少页
$offset = ($curr-1)*$limit;
$sql = "select a.id,a.content,a.pid,a.createtime,b.username,b.email from lyy_message a 
JOIN lyy_member b ON a.uid=b.id where a.del=1 limit $offset,$limit";
$res = mysqli_query(conn(),$sql);
$lists = mysqli_fetch_all($res,MYSQLI_ASSOC);#留言列表
?>
<!DOCTYPE html>
<html>
<head>
    <?php include_once 'common_js_css.php'?>
    <link rel="stylesheet" type="text/css" href="css/adlianxibiao.css">
</head>
<body>
<div class="cont" style="height: 730px">
    <h1 style="text-align: center;">留言列表</h1>
    <form id="form1" style="margin-left: 40px;margin-top: 40px">
      <table width="1000" border="0" align="center" cellspacing="0">
        <tr>
          <th width="30" height="30" scope="col">序号</th>
          <th width="100" height="30" scope="col">用户名</th>
          <th width="120" scope="col">邮箱地址</th>
          <th width="60" scope="col">留言类型</th>
          <th width="250" height="30" scope="col">留言内容</th>
          <th width="150" height="30" scope="col">留言时间</th>
          <th width="60" height="30" scope="col">&nbsp;</th>
        </tr>
          <?php foreach ($lists as $list): ?>
        <tr>
          <td height="30" align="center"><?php echo $list['id']; ?></td>
          <td width="100" height="50" align="center"><p><?php echo $list['username']; ?></p></td>
          <td width="120" height="50" align="center"><?php echo $list['email']; ?></td>
          <td width="60" height="50" align="center"><?php if ($list['pid']==0) echo '留言';else {echo '回复';}?></td>
          <td width="250" height="30" align="center"><?php echo $list['content']; ?></td>
          <td height="30" align="center"><?php echo date('Y-m-d H:i:s',$list['createtime']); ?></td>
          <td height="30" align="center"><input type="submit" onclick="del('lyy_message','<?php echo $list['id'];?>')" value="删除"></td>
        </tr>
          <?php endforeach; ?>
      </table>
    </form>
</div>
</body>
</html>